<?php
use \waf\Waf;
use \waf\log\WLog;

class SUser
{
    public static function doLogin($user_name, $user_pass)
    {
        $conf = Waf::getConfig('db', 'mysql');
        WLog::logInfo("conf = ". WLog::toJson($conf), __FILE__, __LINE__, __FUNCTION__);
        $swoole_mysql = new Swoole\Coroutine\MySQL();
        $swoole_mysql->connect($conf);
        $res = $swoole_mysql->query("select * from mytest where user_name = '{$user_name}' and user_pass = '$user_pass'");

        return $res;
    }

    public static function getConfig($key = '')
    {
        $conf = Waf::getConfig('db', 'redis');
        WLog::logInfo("conf = ". WLog::toJson($conf), __FILE__, __LINE__, __FUNCTION__);
        $redis = new Swoole\Coroutine\Redis();
        $redis->connect($conf['ip'], $conf['port']);
        $val = $redis->get($key);
        return $val;
    }
}